1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
|
2020-07-26 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added first pass of the '8SED' algorithm.
Added the first pass of the 8SED algorithm. The first pass
transverse the bitmap from top to bottom and for each row
it sweeps forward and backward assigning distances to the
grid points.
* src/sdf/ftbsdf.c (ED): Added additional parameter `sign'.
* src/sdf/ftbsdf.c (edt8): Added function to convert bitmap
to SDF using the 8SED algorithm.
* src/sdf/ftbsdf.c (first_pass): Added function to do the
first pass of the 8SED algorithm on the bitmap.
* src/sdf/ftbsdf.c (finalize_sdf): Added function to assign
the final SDF data to the target bitmap.
* src/sdf/ftbsdf.c (*): Various minor or experimental changes.
* src/sdf/ftsdfrend.c (ft_bsdf_render): Fix spacing.
2020-07-25 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c (*): Rename `SDF_TRaster' => `BSDF_TRaster'.
`SDF_TRaster' is for the `sdf' renderer.
2020-07-25 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftbsdf.c: Typo. `FT_16D16' is 16.16 representation.
2020-07-25 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf renderer] Hold a refrence to `FT_Memory'.
Due to the way the 8SED algorithm works we need to keep
a track of distances and nearest point of all the pixels/
grid points.
* src/sdf/ftbsdf.c (BSDF_TRaster): Added struct to
hold the `FT_Memory' reference, to be used to allocate
memory.
* src/sdf/ftbsdf.c (ED, BSDF_Worker): Added few more
essential struct. `ED' contains infomation about the
nearest point. `BSDF_Worker' is used to combine all
the essentail parameters to functions.
* src/sdf/ftbsdf.c (bsdf_copy_source_to_target =>
bsdf_init_distance_map): Renamed.
* src/sdf/ftbsdf.c (*): Various minor changes.
* src/sdf/sdf.c: Change the order of source include
because `ftsdf.c' change some internal freetype
defines which are required in `ftbsdf.c'.
2020-07-25 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf renderer] Convert 8bit bitmap to 16bit.
* src/sdf/ftbsdf.c (bsdf_copy_source_to_target): Added
extra parameter to flip the bitmap vertically.
* src/sdf/ftbsdf.c (bsdf_copy_source_to_target):
Implemented functionality to convert 8bits per
pixel bitmap to a 16bits per pixel bitmap, which
will be used to generate SDF.
2020-07-24 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Started the `bsdf' rasterier.
* src/sdf/ftbsdf.c (*): Fix line endings.
* src/sdf/ftbsdf.c (bsdf_copy_source_to_target): Added
function to copy the source bitmap to the center of
the target bitmap and also convert it to normalized
16 bits per pixel bitmap.
2020-07-19 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added interface functions for `bsdf' converter.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): Remove
the bitmap check which prevent calling renderers
if the glyph is already a bitmap. The `bsdf' renderer
requires a bitmap for conversion.
* src/base/ftobjs.c (ft_add_renderer): Remove the glyph
format check which ensures that the glyph format for
a renderer is `FT_GLYPH_FORMAT_OUTLINE', again the `bsdf'
renderer has `FT_GLYPH_FORMAT_BITMAP' as a glyph format,
so we need to remove the condition to initialize the
renderer properly.
* src/sdf/ftbsdf.c (*): Added a rasterizer for the
`bsdf' renderer and created necessary functions.
* src/sdf/ftbsdf.h: Add forward declaration of the
rasterizer.
* src/sdf/ftsdfrend.c (ft_bitmap_sdf_renderer_class):
Define the new `bsdf' rendere and add the
`FT_Renderer_RenderFunc' function, the rest is
same as the `sdf' renderer.
* src/sdf/ftsdfrend.h: Add forward declaration of the
renderer.
* src/sdf/rules.mk (SDF_DRV_SRC): Add the new `ftbsdf.c'
file to the compile list.
* src/sdf/sdf.c: Inclue the `ftbsdf.c' file if making
single object.
2020-07-19 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Add alloc/free functions.
* src/sdf/ftsdf.c (*): Add `sdf_alloc' and `sdf_free'
to allocate and deallocate memory respectively.
By using function we can directly use them in the
conditional statements, which is not possible when
using `do {} while ( 0 )'.
* src/sdf/ftsdf.c (SDF_MEMORY_TRACKER_): When not
debugging don't leave the macros empty otherwise
some compiler may emit warning because of empty
`;' semi-colon.
2020-07-19 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added new renderer `bsdf'.
* src/sdf/ftsdfrend.* (*): Added new renderer
named `bsdf' which basically convert bitmap
to signed distance fields. This is a part of
the `sdf' module and not a separate module on
it's own.
* src/sdf/module.mk (FTMODULE_H_COMMANDS): Add
the new renderer to the list of modules.
* include/freetype/config/ftmodule.h: Add the
new renderer to default list of modules when
not compiling with GNU Make.
2020-07-18 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Only track memory in debug mode.
* src/sdf/ftsdf.c (*): Disable total memory
usage tracking if the program is not in
debug mode.
2020-07-18 Anuj Verma <anujv@iitbhilai.ac.in>
[sdfb] Removed Module.
Remove sdfb module. Instead of a new module
simply create a new renderer in the `sdf'
module for converting bitmaps to SDF.
2020-07-18 Anuj Verma <anujv@iitbhilai.ac.in>
[sdfb] Fix GNU Make build.
* src/sdfb/rules.mk (SDFB_DRV_H): Fix name of
the module specific error file `ftsdfberrs.h'.
* src/sdf/ftsdf.h (Optimizations): Fix warning.
`warning: comma at end of enumerator list [-Wpedantic]'
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Remove
unused variable `cindex', causes warning.
`warning: unused variable 'cindex' [-Wunused-variable]'
2020-07-17 Anuj Verma <anujv@iitbhilai.ac.in>
[sdfb] Added new module to generate SDF from bitmap.
* src/sdfb/sdfb.c, src/sdfb/ftsdfbrend.c,
src/sdfb/ftsdfb.c, src/sdfb/ftsdfbrend.h,
src/sdfb/ftsdfb.h, src/sdfb/ftsdfberrs.h:
Added files required by the `sdfb' renderer module.
* src/sdfb/rules.mk, src/sdfb/module.mk: Added
files required to build the `sdfb' module using
the default build system.
* CMakeLists.txt (BASE_SRCS): Add `src/sdfb/sdfb.c'
to the variable.
* include/freetype/config/ftmodule.h: Added `sdfb'
module declaration so that the module can be compiled
when not compiling with GNU make.
* modules.cfg (RASTER_MODULES): Include `sdfb' module
to the default rasterizer module list.
* include/freetype/ftmoderr.h: sdfb module error define
* src/sdf/rules.mk: Add EOF.
2020-07-17 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added memory tracker.
* src/sdf/ftsdf.c (SDF_MemoryUser): Added struct
which is used in place of `FT_Memory::user'.
* src/sdf/ftsdf.c (SDF_ALLOC, SDF_FREE): Added macros
for allocating and deallocating memory. These macros
restore the old `FT_Memory::user' before calling the
relevant allocation/deallocation functions so as to
not cause errors while debugging memory. And later
they add the allocated memory size in a variable.
* src/sdf/ftsdf.c (*): Use `SDF_ALLOC', `SDF_FREE'
instead of the `FT_' variant.
2020-07-15 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (sdf_property_set): Minor fix.
2020-07-14 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Temporary change.
Added new property to dynamically change the
optimization to be used to generate the SDF.
This can be used to compare the performance of
different optimization techniques without going
and recompiling the program.
And will also be used in the demo to check the
performance.
2020-07-13 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added more properties.
Added two properties:
- `flip_y': To flip the generated SDF along the y axis.
- `flip_sign': By default outside is treated to have
negative sign, setting `flip_sign' to 1 the outside
pixels will have positive sign.
* src/sdf/ftsdf.* (*): Use the newly added properties.
* src/sdf/ftsdfrend.* (*): Add the newly added properties,
and add functionality to set them using `FT_Property_Set'.
2020-07-13 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Check for left or right fill.
* src/sdf/ftsdf.c (SDF_Params): Added struct which
contains some internal data required by the rater-
izer (such as left/right fill).
* src/sdf/ftsdf.c (sdf_raster_render): Determine the
fill side and pass it to the `sdf_generate_' funcs.
* src/sdf/ftsdf.c (sdf_generate_): Use the new `SDF_Params'
to generate SDF accordingly.
2020-07-12 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Optimize the coarse grid optimization.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Merge
the relevant edge finding loop and shortest dist-
ance search loop. We can find the relevant edges
of a coarse grid and immediately use them to find
the shortest distance of the points in the coarse
grid. This drastically reduce memory usage and
performance.
Also, do the sign assignment of the edges which was
missing.
2020-07-11 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (*): Fixed warnings.
Fixed various warnings and other few errors.
2020-07-11 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Comments.
Add more comments explaining the step by step
process of using coarse grid to increase the
performance of nearest distance search.
2020-07-11 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Memory leak.
Release the allocated lists for the coarse grid after
we are done using them.
2020-07-11 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Completed the coarse grid optimization.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Fixed
an issue with position calculation and upside down
images.
2020-07-10 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Partially completed the coarse grid optimization.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): Added
functionality to check distances of all edges from
the coarse grid and add the relevant edges to the
list.
[Note]: The function is not complete yet.
2020-07-10 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added the coarse grid optimization function.
* src/sdf/ftsdf.c (sdf_generate_coarse_grid): The
function uses coarse grid to optimize nearest edge
search performance.
2020-07-10 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Remove use of `FT_List'.
Simply use a `next' pointer inside `SDF_Edge' and
`SDF_Contour' to create a linked list. This reduces
the number of allocations due to `FT_ListNode', also
we don't need a doubly linked list.
* src/sdf/ftsdf.c (SDF_Edge, SDF_Contour): Remove the
`FT_List' and use a `next' pointer to create the
linked list.
* src/sdf/ftsdf.c(sdf_edge_destructor, sdf_contour_destructor):
Removed, not needed any more.
* src/sdf/ftsdf.c (*): Remove the use of `FT_List_'
functions wherever necessary and sync with the new
list.
2020-07-09 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added subdivision optimization.
* src/sdf/ftsdf.c (sdf_generate_subdivision): The
function generate SDF just like the `sdf_generate'
function, but subdivide the curve into a number of
lines and then use the `sdf_generate_bounding_box'
function to generate SDF.
2020-07-09 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functions to subdivide a cubic curve.
* src/sdf/ftsdf.c (split_cubic, split_sdf_cubic):
These functions can be used to subdivide a
cubic bezier curve into line segments which can
then be used to generate the SDF.
* src/sdf/ftsdf.c (split_sdf_shape): Added function
to split a cubic into a line segments.
* src/sdf/ftsdf.c (sdf_shape_done): No need to pass
`FT_Memory' as a parameter, it can be accessed
from the `shape' struct.
2020-07-09 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (split_sdf_shape): Typo.
2020-07-08 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (split_sdf_shape): Memory leak.
After recursion the edges variable becomes `NULL'
so reassign it to deallocate the list completely.
2020-07-08 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functions to subdivide a conic curve.
* src/sdf/ftsdf.c (split_conic, split_sdf_conic):
These functions can be used to subdivide a
conic bezier curve into line segments which can
then be used to generate the SDF.
* src/sdf/ftsdf.c (split_sdf_shape): Added function
to split a outline into a line segments.
2020-07-06 Anuj Verma <anujv@iitbhilai.ac.in>
* [GSoC]ChangLog: Fixed typos.
2020-07-06 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (sdf_generate_bounding_box): Due to
the way we use the bounding box, we need to keep a track
of signed distances of each pixel so later the sign can
be determined properly. The method is certainly faster
then checking all the pixels against all the edges,
but also require a decent amount of memory to work.
2020-07-06 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Precompute the orthogonality.
* src/sdf/ftsdf.c (SDF_Signed_Distance): Remove unused
fields.
* src/sdf/ftsdf.c (resolve_corner): The function can be
simplified to a single line. Instead of computing
orthogonality here, we precompute it in the corresponding
`get_min_distance_' functions more efficiently.
* src/sdf/ftsdf.c (get_min_distance_): Precompute orthogonality/
cross product of direction and the distance vector. Since
in these function we know that weather the distance vector
and the direction are perpendicular, we can simply set
the cross to 1 (sin(90) = 1) in case they are perpendicular.
This can reduce the number of `FT_Vector_NormLen' calls.
2020-07-05 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added bounding box optimization.
* src/sdf/ftsdfrend.c (sdf_generate_bounding_box): The
function generate SDF just like the `sdf_generate'
function, but uses bounding box to check pixels
efficiently.
* src/sdf/ftsdfrend.c (get_control_box): Added function
to get control box of a `SDF_Edge'.
2020-07-04 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (sdf_shape_dump): Use `%ld' to
printf `signed long' otherwise it gives wrong output.
2020-07-04 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (ft_sdf_render): Don't negate
unsigned integers.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c: Use ASCII single quote (') instead
of back tick (`) for derivatives. Looks cleaner.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to find shortest distance from a
point to a cubic bezier. Now the sdf module can render
all types of fonts, but still has some issues.
* src/sdf/ftsdf.c (get_min_distance_cubic): The function
calculates shortest distance from a point to a cubic
bezier curve.
* src/sdf/ftsdf.c (sdf_edge_get_min_distance): Add the
`get_min_distance_cubic' function call.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (resolve_corner): [Bug] Remove the
nearest_point check. Two distances can be same and
can give opposite sign, but they may not have a
common nearest_point. Also remove distance check
because due to precision errors the two distances can
be really really close. Therefore use epsilon instead.
* src/sdf/ftsdf.c (sdf_contour_get_min_distance): Use
epsilon for comparing distances.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_shape_dump): Add more info
to the debug output.
2020-07-03 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (MAX_NEWTON_ITERATION => MAX_NEWTON_DIVISIONS):
Renamed to avoid confusion.
2020-07-02 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added Newton's method for shortest distance
from a point to a conic.
* src/sdf/ftsdf.c (get_min_distance_conic): Created
a new function with same name which uses Newton's
iteration for finding shortest distance from a point
to a conic curve. This doesn't causes underflow.
* src/sdf/ftsdf.c (USE_NEWTON_FOR_CONIC): This macro
can be used to toggle between Newton or analytical
cubic solving method.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (get_min_distance_conic): Add more
details to why we clamp the roots.
* src/sdf/ftsdf.c: Make sure preprocessor # is always
on the first line.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Make squared distances toggleable.
* src/sdf/ftsdf.c (SDF_Signed_Distance): Renamed
squared_distance to distance. It can now represent
both squared as well as actual distances.
* src/sdf/ftsdf.c (USE_SQUARED_DISTANCES): Added macro
which control weather to do computation is squared
distances or actual distances. This can be used to
avoid overflow when generating large SDF bitmaps.
* src/sdf/ftsdf.c: Make sure not to exceed line length
of 78.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (get_min_distance_conic): In case
the cubic equation returns zero root, use endpoints
for calculating the shortest distance.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to find shortest distance from a
point to a conic bezier. Now the sdf module can render
ttf fonts or fonts with line and conic segments.
* src/sdf/ftsdf.c (get_min_distance_conic): The function
calculates shortest distance from a point to a conic
bezier curve.
* src/sdf/ftsdf.c (sdf_edge_get_min_distance): Add the
`get_min_distance_conic' function call.
2020-07-01 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (get_min_distance_line): First check
pointer before using or dereferencing them.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c: Avoid parentheses if there is only
one statement inside a control-flow statement.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functions to solve polynomial equations.
* src/sdf/ftsdf.c (solve_quadratic_equation,
solve_cubic_equation): Added functions to solve
quadratic and cubic equations. These will be used for
conic bezier curves only.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (square_root, cube_root, arc_cos):
Use FT_16D16 instead of FT_Fixed to avoid confusion.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (cube_root, arc_cos): Added a few
essential math functions.
2020-06-30 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Fixed compilation under gnumake.
* src/sdf/rules.mk (DRV_OBJ_ => DRV_OBJS_): Fixed variable
name so that the sdf can compile.
* src/sdf/module.mk: Fixed spacing.
* src/sdf/*.c: Fixed all compiler warnings.
* [GSoC]ChangLog: Fixed dates.
2020-06-29 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to resolve corners in case of
ambiguity.
* src/sdf/ftsdf.c (resolve_corner): Added function
to determine the correct sign in case there are
two sign for the same shortest distance (happens
around corners).
* src/sdf/ftsdf.c: Typo neartest_point -> nearest_point.
2020-06-29 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] The module can now generate signed distance
fields for outline with only lines.
* src/sdf/ftsdf.c (get_min_distance_line): Calculation
mistake.
* src/sdf/ftsdf.c (square_root): Added function to calculate
square root of a 16.16 fixed point integer.
* src/sdf/ftsdf.c (sdf_generate): Assign values to the output
bitmap, currently the output is 6.10 fixed point which can
contain values from [-32, 32]. Also fixed a bug which was
causing upside down images.
* src/sdf/ftsdfrend.c (ft_sdf_render): Fixed alignment issues.
2020-06-28 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added function to find shortest distance from
a point to a line.
* src/sdf/ftsdf.c (get_min_distance_line): The function
calculate the shortest signed distance from a point
to a line segment.
* src/sdf/ftsdf.c (sdf_contour_get_min_distance): Typo.
* src/sdf/ftsdf.c (SDF_Signed_Distance): Use squared
distance instead of actual distance for performance.
2020-06-28 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (SDF_Iterator_IO): Removed.
* src/sdf/ftsdf.c (sdf_edge_iterator_func => sdf_edge_get_min_distance
sdf_contour_iterator_func => sdf_contour_get_min_distance): Renamed.
Manually iterate through the lists instead of `FT_List_Iterate' to
avoid io structs and looks a bit cleaner.
2020-06-28 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added basic outline of the functions required to
generate sdf.
* src/sdf/ftsdf.c (SDF_Signed_Distance): Added struct which
represent a complete signed distance and can be used to
get cross, dot, sign etc.
* src/sdf/ftsdf.c (SDF_Iterator_IO): This struct will be used
while `FT_List_Iterate'.
* src/sdf/ftsdf.c (sdf_generate): Added function which generate
SDF from `SDF_Shape'.
* src/sdf/ftsdf.c (sdf_edge_iterator_func,
sdf_contour_iterator_func): Added functions
which iterate through contours and edges and return the shortest
distance.
2020-06-27 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added `SDF_Raster_Params' struct which extends
`FT_Raster_Params' and has a few extra fields. This is done
to pass extra data to the sdf rasterizer which is required
while rasterizing.
* src/sdf/ftsdf.h (SDF_Raster_Params): Added a struct which
extends `FT_Raster_Params' and has the `spread' parameter.
Also moved the max, min and default spread values to this
header file.
* src/sdf/ftsdf.c (sdf_raster_render): Added parameter and
attribute checking in order to pick errors and return
early.
* src//sdf/ftsdfrend.c (ft_sdf_render): Setup the `SDF_Raster_Params'
and pass it to the rasterizer instead of `FT_Raster_Params'.
2020-06-27 Anuj Verma <anujv@iitbhilai.ac.in>
* include/freetype/ftimage.h (FT_RASTER_FLAG_): Added
a new raster flag `FT_RASTER_FLAG_SDF'. The `ftsdf'
rasterizer will only render if this flag is set.
* src/sdf/ftsdfrend.c (ft_sdf_render): Set the `flags' field
of `FT_Raster_Params' to `FT_RASTER_FLAG_SDF'.
2020-06-26 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_shape_dump): Use `FT_TRACEX'
instead of `printf'.
2020-06-26 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdf.c (sdf_shape_dump): Added function to
dump the `SDF_Shape' on the console for debugging.
2020-06-26 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functions to de-allocate `SDF_' structs.
* src/sdf/ftsdf.c (SDF_Contour, SDF_Shape): Use `FT_ListRec'
instead of `FT_List' to avoid a few extra allocations.
* src/sdf/ftsdf.c (SDF_Edge, SDF_Contour, SDF_Shape): Added
functions to de-allocate these structs and their members.
* src/sdf/ftsdfrenc.c: Typo.
2020-06-25 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Decompose outline and store it in a temporary
`SDF_Shape' object for easy iteration and pre-computing
some variables.
* src/sdf/ftsdf.c (sdf_outline_decompose): Added function
to decompost outline and store it in a `SDF_Shape' object.
This allows us to pre-compute some variable.
2020-06-25 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added essential enums and structs required.
* src/freetype/internal/fttrace.h: Remove tabs.
* src/sdf/ftsdfrend.c (ft_sdf_render): Calculate padding
using the `spread'.
* src/sdf/ftsdf.c (SDF_Edge_Type, SDF_Edge, SDF_Contour,
SDF_Shape): Added structures and their initializer
functions.
2020-06-23 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added functionality to set and get module properties.
Also added a `spread' property.
* src/freetype/internal/fttrace.h: Added sdf module trace
define.
* src/sdf/ftsdf.c (sdf_TRaster => SDF_TRaster): Use capital
character for structs.
* src/sdf/ftsdfrend.h (SDF_Renderer_Module): Added a struct
which extends the `FT_RendererRec' and added the `spread'
property.
* src/sdf/ftsdfrend.c: Synchronized the code to use the new
`SDF_Renderer_Module' and added functions to get/set the
properties.
2020-06-20 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Implemented a few functions required by a renderer
module.
* src/sdf/ftsdf.c (sdf_TRaster_): Added new structure to hold
the memory allocator `FT_Memory'.
* src/sdf/ftsdf.c (ft_sdf_raster): Implemented a few essential
functions required by `FT_Raster'.
* src/sdf/ftsdfrend.c (ft_sdf_renderer_class): Implemented a few
essential functions required by `FT_Renderer'.
* src/sdf/ftsdfrend.c (ft_sdf_render): Added functionality to
compute shift and padding before rendering the outline.
2020-06-19 Anuj Verma <anujv@iitbhilai.ac.in>
* include/freetype/ftimage.h (FT_Render_Mode_): Added new
pixel mode `FT_PIXEL_MODE_GRAY16' which will be used
to represent signed values while rendering to SDF bitmap.
2020-06-19 Anuj Verma <anujv@iitbhilai.ac.in>
* include/freetype/freetype.h (FT_Render_Mode_): Added new
rendermode `FT_RENDER_MODE_SDF' which will be used by the
`sdf' module to generate signed distance fields from glyph's
outline.
* src/sdf/ftsdfrend.h, src/sdf/module.mk, src/sdf/rules.mk:
Add a new line at the end of files.
2020-06-18 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added the structure of a new module to render
signed distance fields.
* src/sdf/sdf.c, src/sdf/ftsdfrend.c, src/sdf/ftsdf.c,
src/sdf/ftsdfrend.h, src/sdf/ftsdf.h, src/sdf/ftsdferrs.h:
Added files required by the `sdf' renderer module and added
the basic structure and functions required.
* src/sdf/rules.mk, src/sdf/module.mk: Added files required to
build the `sdf' module using the default build system.
* CMakeLists.txt (BASE_SRCS): Add `src/sdf/sdf.c' to the variable.
* include/freetype/config/ftmodule.h: Added `sdf' module
declaration so that the module can be compiled when not compiling
with GNU make.
* modules.cfg (RASTER_MODULES): Include `sdf' module to the default
rasterizer module list.
* include/freetype/ftmoderr.h: sdf module error define
|